/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ch.flagmansworld;

import java.util.Objects;

/**
 * Option-Object with adb-Path, App-Path, if the InfoDialog is show
 * @author Patrick Wachsmuth
 * @version 1.0
 */
public class OptionObj {

    private String adbPath;
    private String appPath;
    private boolean showInfo;

    /**
     * Creates a full OptionObj
     * @param adbPath
     * @param appPath
     * @param showInfo
     * @throws IllegalArgumentException 
     */
    public OptionObj(String adbPath, String appPath, boolean showInfo) throws IllegalArgumentException {
        if (adbPath == null || adbPath.isEmpty() || appPath == null || appPath.isEmpty()) {
            throw new IllegalArgumentException("Parameter are empty or null");
        } else {
            this.adbPath = adbPath;
            this.appPath = appPath;
            this.showInfo = showInfo;
        }
    }

    /**
     * Creates a empty OptionObj
     */
    public OptionObj() {
    }

    /**
     * @return the adbPath
     */
    public String getAdbPath() {
        return adbPath;
    }

    /**
     * @param adbPath the adbPath to set
     * @exception IllegalArgumentException
     */
    public void setAdbPath(String adbPath) throws IllegalArgumentException {
        if (adbPath == null || adbPath.isEmpty()) {
            throw new IllegalArgumentException("Parameter are empty or null");
        } else {
            this.adbPath = adbPath;
        }
    }

    /**
     * @return the appPath
     */
    public String getAppPath() {
        return appPath;
    }

    /**
     * @param appPath the appPath to set
     * @exception IllegalArgumentException
     */
    public void setAppPath(String appPath) throws IllegalArgumentException {
        if (appPath == null || appPath.isEmpty()) {
            throw new IllegalArgumentException("Parameter are empty or null");
        } else {
            this.appPath = appPath;
        }
    }

    /**
     * @return the showInfo
     */
    public boolean isShowInfo() {
        return showInfo;
    }

    /**
     * @param showInfo the showInfo to set
     */
    public void setShowInfo(boolean showInfo) {
        this.showInfo = showInfo;
    }

    /**
     * Returns the Object as String
     * @return Object as String
     */
    @Override
    public String toString() {
        return "adb-Path: " + this.getAdbPath() + " App-Path: " + this.getAppPath() + " showInofDialog: " + this.isShowInfo();
    }

    /**
     * Merge two Objects
     * @param obj
     * @return true if the Objects are identical. Otherwise false
     */
    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (obj == this) {
            return true;
        }
        if (this.getClass() == obj.getClass()) {
            OptionObj a = (OptionObj) obj;
            if (this.hashCode() == a.hashCode()) {
                if (this.isEqualTo(a)) {
                    return true;
                } else {
                    return false;
                }
            } else {
                return false;
            }
        }

        return false;
    }

    /**
     * Generates the HashCode from the actual Object
     * @return the hash
     */
    public int hashCode() {
        int hash = 3;
        hash = 31 * hash + Objects.hashCode(this.adbPath);
        hash = 31 * hash + Objects.hashCode(this.appPath);
        hash = 31 * hash + (this.showInfo ? 1 : 0);
        return hash;
    }

    /**
     * Method to Compare the Objects with the Values for each Attribute
     * @param obj
     * @return true if the Object-Params are identical. Otherwise false
     */
    private boolean isEqualTo(OptionObj obj) {
        if (!this.adbPath.equals(obj.adbPath)) {
            return false;
        }
        if (!this.appPath.equals(obj.appPath)) {
            return false;
        }
        if (!this.showInfo == obj.showInfo) {
            return false;
        }

        return true;
    }
}
